<template>
  <div class="todo-footer">
    <label >
      <input type="checkbox" @change="selectAll" v-model="check">
    </label>
    <span>
      <span>已完成{{ doneCount }}</span>/全部{{ todos.length}}
    </span>
    <button class="btn btn-danger" @click="clear">清除已完成任务</button>
  </div>
</template>

<script>
export default {
  name: 'Footer-2',
  data () {
    return {
      check: false
    }
  },
  methods: {
    selectAll () {
      this.$emit('allDone', this.check)
    },
    clear () {
      this.clearAllDone()
      this.check = false
    }
  },
  props: {
    todos: Array,
    doneCount: Number,
    clearAllDone: Function,
    doneAll: Boolean
  },
  watch: {
    doneAll: {
      handler (val) {
        this.check = val
      }
    }
  }
}
</script>

<style lang="less" scoped>
  .todo-footer{
    height: 40px;
    line-height: 40px;
    padding-left: 6px;
    margin-top: 5px;
    label{
      display: inline-block;
      margin-right: 20px;
      cursor: pointer;
      input{
        position: relative;
        top: -1px;
        vertical-align: middle;
      }
    }
    button{
      float: right;
      margin-top: 5px;
    }
  }
</style>
